# -*- coding: utf-8 -*-

from urlparse import urljoin

from django.conf import settings


def absolute_url(path, prefix=None):
    if path.startswith(('http://', 'https://', '/')):
        return path
    if prefix is None:
        if settings.STATIC_URL is None:
             # backwards compatibility
            prefix = settings.MEDIA_URL
        else:
            prefix = settings.STATIC_URL
    return urljoin(prefix, path)
